// 操作cookie
import Cookies from 'js-cookie'

// UserState
const tokenKey = 'token'

export const getToken = () => {
    return Cookies.get(tokenKey) as string
}
export const setToken = (token: string) => {
    // 设置过期时间为十五分钟
    const millisecond = new Date().getTime()
    const expiresTime = new Date(millisecond + 60 * 1000 * 10)
    Cookies.set(tokenKey, token, { expires: expiresTime })
}

export const removeToken = () => Cookies.remove(tokenKey)
